/*
package com.lx.controller;

import com.lx.entity.Order_Old;
import com.lx.service.OrderService_Old;
import com.lx.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api")
@Api(tags = "订单管理接口")
public class OrderController_Old {
    @Autowired
    OrderService_Old orderService;

    @PostMapping("/order/pageinfo")
    @ApiOperation(value = "分页查询订单列表", notes = "根据条件查询分页列表")
    public Result getPageInfo(@ApiParam(value = "查询参数", required = true) @RequestBody Map<String, Object> params) {
        // 清理空参数
        if (params.containsKey("loginName") &&
                (params.get("loginName") == null || params.get("loginName").toString().isEmpty())) {
            params.remove("loginName");
        }

        if (params.containsKey("serialNumber") &&
                (params.get("serialNumber") == null || params.get("serialNumber").toString().isEmpty())) {
            params.remove("serialNumber");
        }

        if (params.containsKey("createTime") &&
                (params.get("createTime") == null || params.get("createTime").toString().isEmpty())) {
            params.remove("createTime");
        }

        return Result.success(5200, "获取订单列表成功").add("pageinfo", orderService.getPageInfo(params));
    }

    @PostMapping("/order/add")
    @ApiOperation(value = "添加订单", notes = "添加新的订单")
    public Result addOrder(@ApiParam(value = "订单信息参数", required = true) @RequestBody Map<String, Object> params) {
        Order_Old order = new Order_Old();
            // 从参数中提取订单信息
            if (params.containsKey("userId")) {
                order.setUserId(Integer.parseInt(params.get("userId").toString()));
            } else {
                return Result.error(5500, "用户ID不能为空");
            }
          if (params.containsKey("quantity")) {
            order.setQuantity((Integer) params.get("quantity"));
         }

            if (params.containsKey("loginName")) {
                order.setLoginName(params.get("loginName").toString());
            }
            if (params.containsKey("userAddress")) {
                order.setUserAddress(params.get("userAddress").toString());
            }
            if (params.containsKey("serialNumber")) {
                order.setSerialNumber(params.get("serialNumber").toString());
            }
            if (params.containsKey("isPay")) {
                order.setIsPay(Integer.parseInt(params.get("isPay").toString()));
            }

            // 提取商品相关信息
            Integer productId = null;
            if (params.containsKey("productId")) {
                productId = Integer.parseInt(params.get("productId").toString());
            } else {
                return Result.error(5500, "商品ID不能为空");
            }
            boolean result = orderService.addOrder(order, productId);
            if (result) {
                return Result.success(5200, "添加订单成功");
            } else {
                return Result.error(5500, "添加订单失败");
            }

    }

    @PostMapping("/order/update")
    @ApiOperation(value = "修改订单", notes = "修改订单信息")
    public Result updateOrder(@ApiParam(value = "订单信息参数", required = true) @RequestBody Map<String, Object> params) {
        Order_Old order = new Order_Old();


            if (params.containsKey("id")) {
                order.setId(Integer.parseInt(params.get("id").toString()));
            } else {
                return Result.error(5500, "订单ID不能为空");
            }

            if (params.containsKey("isPay")) {
                order.setIsPay(Integer.parseInt(params.get("isPay").toString()));
            }
            boolean result = orderService.updateOrder(order);
            if (result) {
                return Result.success(5200, "更新订单成功");
            } else {
                return Result.error(5500, "更新订单失败");
            }

    }

    @PostMapping("/order/delete")
    @ApiOperation(value = "删除订单", notes = "删除订单")
    public Result deleteOrder(@ApiParam(value = "订单ID参数", required = true) @RequestBody Map<String, Object> params) {
            int id = Integer.parseInt(params.get("id").toString());
            boolean result = orderService.delOrder(id);
            if (result) {
                return Result.success(5200, "删除订单成功");
            } else {
                return Result.error(5500, "删除订单失败");
            }
    }



}
*/
